package com.ease.util.configuration {

   import com.ease.util.StringUtils;

   /**
    * Essentially contains a key-value pair with related user visible information.
    */
   public class ConfigurationProperty {

      /**
       * Used to identify a configuration.
       */
      public var key:String;

      /**
       * Value of the configuration.
       */
      public var value:Object;

      /**
       * Label of the configuration which can be used as a user visible identifier.
       */
      public var label:String;

      /**
       * Description which explains usage of the configuration.
       */
      public var description:String;

      /**
       * Copies over meta properties like label, description and categoryId from source
       * to destination if they are not set in the destination.
       */
      public static function copyMissingMetaProperties(
         destination:ConfigurationProperty,
         source:ConfigurationProperty ):void {
         if (destination == null || source == null || destination.key != source.key) {
            return;
         }
         if (StringUtils.isNullorEmpty( destination.description )) {
            destination.description = source.description;
         }
         if (StringUtils.isNullorEmpty( destination.label )) {
            destination.label = source.label;
         }
      }
   }
}